<template>
  <div>
      <div class = "sousuo">
        当前列表><span v-if="this.status>0">已激活</span><span v-else>未激活</span>
        <br>
        <i-button type="info" size="small"  @click="getListInfo(1)">已激活</i-button>
        <i-button type="info" size="small"  @click="getListInfo(0)">未激活</i-button>
      </div>
      <Row class="body">
        <i-col span="4">用户编号</i-col>
        <i-col span="4">姓名</i-col>
        <i-col span="4">电话</i-col>
        <i-col span="4">是否是合伙人</i-col>
        <i-col span="4">提交时间</i-col>
        <i-col span="4">操作</i-col>
      </Row>

      <Row class="list" v-for="item of userList" :key="item.name">
        <i-col span="4">{{item.userId==''?'-':item.userId}} </i-col>
        <i-col span="4">{{item.username==''?'-':item.username}}</i-col>
        <i-col span="4">{{item.phone==''?'-':item.phone}}</i-col>
        <i-col span="4">{{item.isPartner==1?'是':'否'}}</i-col>
        <i-col span="4">{{item.updateTime}}&nbsp;</i-col>
        <i-col span="4">
          <i-button v-if="item.level==0" type="info" size="small"  @click="handleUpdateManager(item.phone)">激活成为合伙人</i-button>
        </i-col>
      </Row>

       <div class="page">
        <Page :total="total" :page-size="pageSize" @on-change="handlePage"></Page>
      </div>

      <Modal
        v-model="modal1"
        title="提示框"
        @on-ok="ok"
        @on-cancel="cancel">
        <p>终端编号:<i-input type="text" v-model="terminalNumber"></i-input></p>
        <p>激活之前您必须填写该用户购买pos机的终端编号</p>
        <p>请确认是否激活该用户</p>
      </Modal>

  </div>



</template>

<script>
import axios from 'axios'
export default {
  name: 'UserList',
  data () {
    return {
        pageSize:10,
        pageNumber:1,
        total:0,
        userList:'',
        username:'',
        phone:'',
        status:0,
        terminalNumber:'',
        modal1: false
      }
  },
  methods: {
    handlePage(res){
      axios.post('/web/api/manager/buyPosjiUserList',{"pageSize":this.pageSize,"page":res,"status":this.status}).then(this.getListInfoSucc)
    },
    getListInfo (status) {
      this.status = status
      axios.post('/web/api/manager/buyPosjiUserList',{"pageSize":this.pageSize,"page":this.pageNumber,"status":status}).then(this.getListInfoSucc)
    },
    getListInfoSucc (res) {
      console.log('POS机用户列表，激活不激活===', res)
      this.total = res.data.date.total
      this.userList = res.data.date.list
    },
    ok () {
        if(this.terminalNumber===''){
          this.$Message.error('请输入终端编号');
          return;
        }
        axios.post('/web/api/manager/initPartner',{"phone":this.phone,"level":'9',"terminalNumber":this.terminalNumber}).then(this.updateInfoSucc)
    },
    cancel () {
        this.$Message.info('取消成功');
    },
    handleUpdateManager (phone) {
      this.modal1 = true;
      this.phone = phone;
    },
    updateInfoSucc (res) {
      console.log('修改', res)
      this.$Message.success(res.data.message)
      this.getListInfo(0);
    },
  },
  mounted () {
    this.getListInfo(0);
  }
}
</script>
<style lang="stylus" scoped>
  .body
    width: 100%
    line-height 3
    font-size 14px
    color #2680c4
    background #eff3fa
    text-align center
  .list
    line-height 3
    font-size 14px
    text-align center
    color #2680c4
  .sousuo
    width 100%
    text-align center
    margin-top 2rem
    margin-bottom 2rem
  .page
    width 100%
    margin-top 2rem
    text-align center
</style>

